/**
 * 作者: heweiping
 * 日期: 2025-04-10 15:46:50
 * 备注: 用户公共活动信息表
 */
package com.motu.monstercity.server.game.userdata;

import com.motu.monstercity.protocol.Common;
import com.motu.vertx.module.utility.toolset.Tool;
import io.vertx.core.json.JsonArray;

public class UserCommonAct extends UserCommonActModel {
    public UserCommonAct() {
        super();
    }

    public Common.PBActHundredDraw.Builder takeHundredDrawInitBuilder() {
        Common.PBActHundredDraw.Builder builder = Common.PBActHundredDraw.newBuilder();
        if (!Tool.isEmpty(getHundredDrawGet())) {
            JsonArray arr = getHundredDrawGetArray();
            for (int i = 0; i < arr.size(); i++) {
                builder.addHundredDrawGet(arr.getInteger(i));
            }
        }
        if (!Tool.isEmpty(hundredCharge)) {
            JsonArray arr = getHundredChargeArray();
            for (int i = 0; i < arr.size(); i++) {
                builder.addHundredCharge(arr.getInteger(i));
            }
        }
        if (!Tool.isEmpty(chargeHundredDrawGet)) {
            JsonArray arr = getChargeHundredDrawGetArray();
            for (int i = 0; i < arr.size(); i++) {
                builder.addChargeHundredDrawGet(arr.getInteger(i));
            }
        }
        return builder;
    }

    public Common.PBActHundredDraw.Builder takeHundredDrawBuilder() {
        if (updateObj == null || updateObj.isEmpty()) {
            return takeHundredDrawInitBuilder();
        }
        Common.PBActHundredDraw.Builder builder = Common.PBActHundredDraw.newBuilder();
        if (isFieldUpdate("hundredDrawGet")) {
            JsonArray arr = getHundredDrawGetArray();
            if (!arr.isEmpty()) {
                for (int i = 0; i < arr.size(); i++) {
                    builder.addHundredDrawGet(arr.getInteger(i));
                }
            } else {
                builder.clearHundredDrawDay();
            }
        }
        if (isFieldUpdate("hundredCharge")) {
            JsonArray arr = getHundredChargeArray();
            if (!arr.isEmpty()) {
                for (int i = 0; i < arr.size(); i++) {
                    builder.addHundredCharge(arr.getInteger(i));
                }
            } else {
                builder.clearHundredCharge();
            }
        }
        if (isFieldUpdate("chargeHundredDrawGet")) {
            JsonArray arr = getChargeHundredDrawGetArray();
            if (!arr.isEmpty()) {
                for (int i = 0; i < arr.size(); i++) {
                    builder.addChargeHundredDrawGet(arr.getInteger(i));
                }
            } else {
                builder.clearChargeHundredDrawGet();
            }
        }
        if (builder.build().toByteArray().length == 0) {
            return takeHundredDrawInitBuilder();
        }
        return builder;
    }

}
